<template>
	<view>
		<u-navbar title="个人中心" titleStyle="color:#fff;" :placeholder="false" leftIconColor="#fff" :autoBack="true" bgColor="rgba(0,0,0,0)">
			
		</u-navbar>
		
		<view class="page_bg">
			<image class="bg_img" v-if="userInfo.cover" :src="userInfo.cover" mode="aspectFill"></image>
			<image class="bg_img" v-else :src="userInfo.avatar" mode="aspectFill"></image>
			<view class="my_info">
				<image v-if="userInfo.avatar" class="head" :src="userInfo.avatar" mode="aspectFill"></image>
				<image v-else class="head" src="../../static/img/ico_head.png" mode="aspectFill"></image>
				<view class="item">
					<view v-if="userInfo.first_name" class="name">
						{{userInfo.first_name}}
					</view>
					<view v-if="userInfo.t_id" class="text">
						推氪号:{{userInfo.t_id}}
					</view>
				</view>
				<!-- <view class="exit" @click="clickExit">
					退出账号
				</view> -->
			</view>
		</view>
		
		<view class="my_bg">
			<view class="my_detail">
				<view class="info">
					<navigator class="item" url="/myPages/fans/fans?tabs=0" hover-class="none">
						<view class="num">{{followData.my_follow}}</view>
						<view class="name">关注</view>
					</navigator>
					<navigator class="item" url="/myPages/fans/fans?tabs=1" hover-class="none">
						<view class="num">{{followData.followed_me}}</view>
						<view class="name">粉丝</view>
					</navigator>
					<view class="item">
						<view class="num">{{followData.subscribe}}</view>
						<view class="name">订阅</view>
					</view>
					<navigator class="btn_text" url="/myPages/editInfo/editInfo" hover-class="none">
						编辑资料
					</navigator>
					<view class="btn_feature" @click="showFeature = true">
						<u-icon name="list" color="#fff" size="50rpx"></u-icon>
					</view>
				</view>
				
				<view v-if="userInfo.biography" class="text">
					{{userInfo.biography}}
				</view>
				<view v-else class="text">
					暂无简介...
				</view>
			</view>
			
			<view class="my_nav">
				
				<navigator class="item" url="/myPages/create/create" hover-class="none">
					<image class="ico" src="../../static/img/ico_10.png" mode="widthFix"></image>
					<view class="name">
						创作中心
					</view>
				</navigator>
				
				<navigator class="item" url="/vipPages/invite/invite" hover-class="none">
					<image class="ico" src="../../static/img/ico_21.png" mode="widthFix"></image>
					<view class="name">
						邀请推广
					</view>
				</navigator>
				<navigator class="item" url="/vipPages/krypton/krypton" hover-class="none">
					<image class="ico" src="../../static/img/ico_22.png" mode="widthFix"></image>
					<view class="name">
						氪气中心
					</view>
				</navigator>
				<navigator class="item" url="/myPages/history/history" hover-class="none">
					<image class="ico" src="../../static/img/ico_9.png" mode="widthFix"></image>
					<view class="name">
						观看历史
					</view>
				</navigator>
				<navigator class="item" url="/vipPages/createVip/createVip" hover-class="none">
					<image class="ico" src="../../static/img/ico_23.png" mode="widthFix"></image>
					<view class="name">
						创作会员
					</view>
				</navigator>
				<!-- <navigator class="item" url="#" hover-class="none">
					<image class="ico" src="../../static/img/ico_11.png" mode="widthFix"></image>
					<view class="name">
						我的订阅
					</view>
				</navigator> -->
			</view>
			
			<view class="all_scene">
				<view class="scene_tabs">
					<!-- <view class="item" :class="tabsIndex == 0?'hover':''" @click="clickTabs(0)">
						场景
					</view> -->
					<view class="item" :class="tabsIndex == 0?'hover':''" @click="clickTabs(0)">
						公开
					</view>
					<view class="item" :class="tabsIndex == 2?'hover':''" @click="clickTabs(2)">
						会员
					</view>
					<view class="item" :class="tabsIndex == 1?'hover':''" @click="clickTabs(1)">
						密友
					</view>
					<view class="item" :class="tabsIndex == 4?'hover':''" @click="clickTabs(4)">
						个人
					</view>
				</view>
				
				<u-empty v-if="myLIvesData.length == 0" mode="data" marginTop="150rpx" icon="/static/img/ico_none.png" ></u-empty>
				<view v-else class="list">
					<view class="item" v-for="(item,index) in myLIvesData" @click="clickGotoHome(item.id)" :key="index">
						<image class="ph" :src="item.file" mode="aspectFill"></image>
						<view class="name">
							{{item.name}}
						</view>
					</view>
				</view>
				
			</view>
			
		</view>
		
		
		<!-- 更多功能 -->
		<u-popup :show="showFeature" :safeAreaInsetTop="true" bgColor="#1F1F1F" mode="right" @close="closeFeature" @open="openFeature">
			<view class="feature">
				<view class="title">
					更多功能
				</view>
				<view class="list">
					<navigator class="item" url="/myPages/create/create" hover-class="none">
						<image class="ico" src="../../static/img/ico_31.png" mode="widthFix"></image>
						<view class="name">
							创作中心
						</view>
					</navigator>
					<navigator class="item" url="/vipPages/krypton/krypton" hover-class="none">
						<image class="ico" src="../../static/img/ico_32.png" mode="widthFix"></image>
						<view class="name">
							氪气中心
						</view>
					</navigator>
					<view class="line"></view>
					<navigator class="item" url="/vipPages/invite/invite" hover-class="none">
						<image class="ico" src="../../static/img/ico_33.png" mode="widthFix"></image>
						<view class="name">
							邀请分享
						</view>
					</navigator>
					<navigator class="item" url="/myPages/history/history" hover-class="none">
						<image class="ico" src="../../static/img/ico_34.png" mode="widthFix"></image>
						<view class="name">
							观看历史
						</view>
					</navigator>
					<view class="item" style="display: none;">
						<image class="ico" src="../../static/img/ico_35.png" mode="widthFix"></image>
						<view class="name">
							我的组织
						</view>
					</view>
					<view class="line"></view>
					<view class="item" style="display: none;">
						<image class="ico" src="../../static/img/ico_36.png" mode="widthFix"></image>
						<view class="name">
							兑换码
						</view>
					</view>
					<view class="item" style="display: none;">
						<image class="ico" src="../../static/img/ico_36.png" mode="widthFix"></image>
						<view class="name">
							我的钱包
						</view>
					</view>
					<view class="item" @click="contact_service">
						<image class="ico" src="../../static/img/ico_37.png" mode="widthFix"></image>
						<text class="name" style="background: none;color: #fff;padding: none;position: absolute;padding-left: 64rpx;">
							联系客服
						</text>
					</view>
					<navigator class="item" url="/aboutUs/aboutUs"  hover-class="none">
						<image class="ico" src="../../static/img/ico_38.png" mode="widthFix"></image>
						<view class="name">
							关于我们
						</view>
					</navigator>
					<view class="line"></view>
					<navigator class="item"  v-for="(item,index) in settingData.webview" :key="index"  :url="'/aboutUs/webView?title='+item.title+'&weburl='+encodeURIComponent(item.weburl)"  hover-class="none">
						<image class="ico" :src="item.icon" mode="widthFix"></image>
						<view class="name">
							{{item.title}}
						</view>
					</navigator>
					
				</view>
				<view class="btn" @click="clickExit">
					退出账号
				</view>
			</view>
		</u-popup>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabsIndex:0,
				userInfo:{},
				settingData:{},
				userId:'',
				followData:{},
				myLIvesData: [],
				showFeature: false
			}
		},
		onLoad() {
			this.userId = uni.getStorageSync('userId');
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
			console.log('userInfo-------',this.userInfo)
			this.getStatiscticsData()
			this.getMyAigcLivesList()
			this.getVipSettings();
		},
		onShow() {
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
		},
		methods: {
			contact_service(){
				uni.showModal({
					title: '请联系客服',
					content: '010-123456',
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			getVipSettings() {
				uni.$u.http.get('/api/vip_settings?from=miniprogram').then(res => {
					console.log('系统配置接口----', res.data.data)
					this.settingData = res.data.data
					
				}).catch(err => {
					console.log(err)
				})
			},
			
			openFeature() {
			  // console.log('open');
			},
			closeFeature() {
			  this.showFeature = false
			  // console.log('close');
			},
			// 退出账号
			clickExit(){
				const that = this
				uni.showModal({
					title: '提示',
					content: '确定退出账号？',
					success: function (resp) {
						if (resp.confirm) {
							uni.setStorageSync("userInfo", '');
							uni.setStorageSync("token", '');
							uni.setStorageSync("isLogin", false);
							uni.setStorageSync("userId", '');
							uni.reLaunch({
								url: '/pages/index/index'
							});
						}
					},
				});
			},
			clickTabs(index){
				this.tabsIndex = index
				this.getMyAigcLivesList()
			},
			clickGotoHome(id){
				uni.reLaunch({
					url: '/pages/index/index?liveId='+id
				});
			},
			// 我的互动场景
			getMyAigcLivesList(){
				uni.$u.http.get('/api/aigc_lives_list/'+this.userId +'?from=miniprogram&is_private='+this.tabsIndex+'&count=999').then(res => {
					console.log('我的互动场景-----',res.data.data)
					this.myLIvesData = res.data.data
				}).catch(err => {
					console.log(err)
				})
			},
			// 用户关注粉丝订阅
			getStatiscticsData(){
				uni.$u.http.get('/api/speed_data_statisctics/?user_id='+this.userInfo.user_id+'&from=miniprogram').then(res => {
					console.log('speed_data_statisctics',res.data)
					this.followData = res.data.data
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.feature{
	width: 480rpx;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-direction: column;
	.title{
		width: 100%;
		margin-top: 60rpx;
		font-size: 30rpx;
		line-height: 40rpx;
		padding:20rpx 40rpx;
		flex-shrink: 0;
		box-sizing: border-box;
	}
	.btn{
		flex-shrink: 0;
		width: 390rpx;
		line-height: 82rpx;
		text-align: center;
		border-radius: 10rpx;
		opacity: 1;
		box-sizing: border-box;
		border: 2rpx solid #A7A7A7;
		font-size: 30prx;
		color: #A7A7A7;
		margin-bottom: 50rpx;
		margin-top: 40rpx;
	}
	.list{
		width: 100%;
		height: 100%;
		border-bottom:1px solid #323232;
		.line{
			border-bottom:1px solid #323232;
			margin: 25rpx 0;
		}
		.item{
			display: flex;
			align-items: center;
			padding:25rpx 40rpx;
			.ico{
				flex-shrink: 0;
				width: 40rpx;
				height: 40rpx;
				margin-right: 25rpx;
			}
			.name{
				font-size: 26rpx;
				line-height: 38rpx;
				line-height: 30rpx;
			}
		}
	}
}
.scene_tabs{
	display: flex;
	align-items: center;
	padding:0 0 6rpx;
	.item{
		font-size: 26rpx;
		font-weight: normal;
		line-height: 40rpx;
		color: #A7A7A7;
		margin-right: 40rpx;
		position: relative;
		&.hover{
			color:#fff;
			font-size: 26rpx;
			font-weight: 600;
			&::after{
				content: '';
				position: absolute;
				left:50%;
				bottom: -6rpx;
				width: 40rpx;
				height: 5rpx;
				margin-left: -20rpx;
				border-radius: 3rpx;
				background: #FFB200;
			}
		}
	}
}
.my_nav{
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 40rpx 0;
	.item{
		padding:0 0rpx;
	}
	.ico{
		display: block;
		width: 50rpx;
		height: 50rpx;
		margin: 0 auto;
	}
	.name{
		font-size: 24rpx;
		font-weight: normal;
		color: #A7A7A7;
		padding-top: 10rpx;
		text-align: center;
	}
}
.all_scene{
	padding:0 10rpx;
	.title{
		font-size: 26rpx;
		font-weight: 600;
		line-height: 40rpx;
		color: #FFFFFF;
		padding-top: 40rpx;
	}
	.list{
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		flex-wrap: wrap;
		margin-left: -30rpx;
		.item{
			width: 203rpx;
			height: 360rpx;
			position: relative;
			margin-top: 30rpx;
			margin-left: 30rpx;
			&:last-child{
				margin-right: auto;
			}
			.lock{
				position: absolute;
				left:0;
				right: 0;
				top:0;
				bottom: 0;
				z-index: 9;
				display: flex;
				align-items: center;
				justify-content: center;
				.ico_8{
					width: 36rpx;
				}
			}
			.ph{
				display: block;
				width: 100%;
				height: 360rpx;
				border-radius: 10rpx;
			}
			.name{
				position: absolute;
				left:0;
				bottom: 0;
				right: 0;
				font-size: 22rpx;
				font-weight: normal;
				line-height: 32rpx;
				text-align: justify;
				color: #FFFFFF;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.5);
				padding:10rpx;
			}
		}
	}
}
.my_bg{
	position: relative;
	z-index: 10;
	background: #1F1F1F;
	border-radius: 30rpx 30rpx 0 0;
	padding:0 30rpx;
	margin-top: -120rpx;
}
.my_detail{
	.text{
		width: 530rpx;
		font-size: 26rpx;
		font-weight: normal;
		line-height: 40rpx;
		color: #FFFFFF;
	}
	.info{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding:40rpx 0;
		.item{
			text-align: center;
			margin-right: 40rpx;
			padding:0 10rpx;
			.num{
				font-size: 30rpx;
				font-weight: 900;
				line-height: 44rpx;
				text-align: justify;
				color:#fff;
				text-align: center;
			}
			.name{
				font-size: 24rpx;
				font-weight: 500;
				line-height: 36rpx;
				text-align: justify;
				letter-spacing: 0px;
				color: #A7A7A7;
				text-align: center;
			}
		}
		.btn_feature{
			border-radius: 10rpx;
			background: #484848;
			width: 70rpx;
			height: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-shrink: 0;
			margin-left: 20rpx;
		}
		.btn_text{
			width: 188rpx;
			height: 70rpx;
			border-radius: 10rpx;
			background: #484848;
			font-size: 26rpx;
			font-weight: normal;
			line-height: 70rpx;
			text-align: justify;
			color: #FFFFFF;
			text-align: center;
			margin-left: auto;
		}
		.btn{
			margin-left: auto;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			font-weight: 500;
			line-height: 42rpx;
			text-align: justify;
			color:#fff;
			.btn_ico{
				width: 60rpx;
				height: 60rpx;
				border-radius: 10rpx;
				background: #484848;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 16rpx;
				.ico{
					width: 35rpx;
					height: 35rpx;
				}
			}
		}
	}
}
.page_bg{
	width: 100%;
	height: 540rpx;
	overflow: hidden;
	position: relative;
	background: rgba(0, 0, 0, 0);
	background-repeat: no-repeat;
	background-size:100% auto;
	position: relative;
	.bg_img{
		width: 100%;
		opacity: 0.5;
	}
	
	.my_info{
		width: 100%;
		display: flex;
		align-items: center;
		padding:0 40rpx;
		box-sizing: border-box;
		position: absolute;
		left:0;
		right: 0;
		bottom: 180rpx;
		.exit{
			flex-shrink: 0;
			font-size: 22rpx;
			padding:0 25rpx;
			line-height: 60rpx;
			border-radius: 36rpx;
			color:#A7A7A7;
			border: 1rpx solid #A7A7A7;
			background: rgba(0, 0, 0, 0.2);
		}
		.head{
			flex-shrink: 0;
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			margin-right: 30rpx;
		}
		.item{
			width: 100%;
			.name{
				font-size: 36rpx;
				font-weight: 600;
				line-height: 54rpx;
				text-align: justify;
				letter-spacing: 0px;
				color: #FFFFFF;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.5);
			}
			.text{
				margin-top: 14rpx;
				font-size: 28rpx;
				font-weight: normal;
				line-height: 42rpx;
				text-align: justify;
				letter-spacing: 0px;
				color: #A7A7A7;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.5);
			}
		}
	}
}
</style>
